export default {
    namespaced: true,
    state: {
        isShowToast: false,
        toastMsg: '0', // 状态值
        toastType: 'success' // warning    danger
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow;
            // 提示显示才会执行提示类型和提示内容
            if (payload.isShow) {
                state.toastMsg = payload.title;
                state.toastType = payload.type;
            }
        }
    },
    // 异步设置定时器修改 isShowToast 的值为 false 
    // 改 changeIsShowToast
    actions: {
        // {commit}   解构
        asyncChangeIsShowToast({
            commit
        }, payload) {
            // console.log('异步actions');
            commit('changeIsShowToast', payload)
            setTimeout(() => {
                commit('changeIsShowToast', {
                    isShow: false
                })
            }, 1500);
        }
    }
}